import exceptions.RentalException;
import rental.DVD;
import rental.Rent;
import junit.framework.TestCase;


public class TestRent extends TestCase {
	Rent rent; 
	DVD dvdR;
	DVD dvdN;
	DVD dvdFK;
	
	protected void setUp() throws Exception {
		dvdR = new DVD("regular", DVD.REGULAR);
		dvdN = new DVD("new", DVD.NEW_MOVIE);
		dvdFK = new DVD("kids", DVD.FOR_KIDS);
		rent = new Rent(dvdR, 2);
	}

	public void testRent() throws RentalException {
		try {
			rent = new Rent(dvdR, 0);
			fail();
		} catch (RentalException e) {
			assertEquals("The renting must have at least one day.", e.getMessage());
		}
		rent = new Rent(dvdR, 2);
		rent = new Rent(dvdR, 5);
		rent = new Rent(dvdR, 100);
	}

	public void testGetDVD() {
		assertSame(dvdR, rent.getDVD());
	}

	public void testGetRentDays() {
		assertEquals(2, rent.getRentDays());
	}

	public void testGetRentValue1() throws RentalException {
		assertEquals(2.0, rent.getRentValue());
		assertEquals(5.0, new Rent(dvdR, 4).getRentValue());
		assertEquals(6.5, new Rent(dvdR, 5).getRentValue());
		assertEquals(14.0, new Rent(dvdR, 10).getRentValue());
		assertEquals(149.0, new Rent(dvdR, 100).getRentValue());
		assertEquals(1499.0, new Rent(dvdR, 1000).getRentValue());
	}
	
	public void testGetRentValue2() throws RentalException{
		assertEquals(3.0, new Rent(dvdN, 1).getRentValue());
		assertEquals(9.0, new Rent(dvdN, 3).getRentValue());
		assertEquals(15.0, new Rent(dvdN, 5).getRentValue());
		assertEquals(30.0, new Rent(dvdN, 10).getRentValue());
		assertEquals(300.0, new Rent(dvdN, 100).getRentValue());
		assertEquals(3000.0, new Rent(dvdN, 1000).getRentValue());
	}
	
	
	public void testGetRentValue3() throws RentalException{
		assertEquals(1.5, new Rent(dvdFK, 1).getRentValue());
		assertEquals(1.5, new Rent(dvdFK, 2).getRentValue());
		assertEquals(1.5, new Rent(dvdFK, 3).getRentValue());
		assertEquals(3.0, new Rent(dvdFK, 4).getRentValue());
		assertEquals(4.5, new Rent(dvdFK, 5).getRentValue());
		assertEquals(12.0, new Rent(dvdFK, 10).getRentValue());
		assertEquals(147.0, new Rent(dvdFK, 100).getRentValue());
		assertEquals(1497.0, new Rent(dvdFK, 1000).getRentValue());
	}
	
	public void testGetProgramPoints1() throws RentalException {
		assertEquals(1, new Rent(dvdFK, 1).getProgramPoints());
		assertEquals(1, new Rent(dvdFK, 5).getProgramPoints());
		assertEquals(1, new Rent(dvdFK, 10).getProgramPoints());
		assertEquals(1, new Rent(dvdFK, 100).getProgramPoints());
	}
	
	public void testGetProgramPoints2() throws RentalException {
		assertEquals(1, new Rent(dvdR, 1).getProgramPoints());
		assertEquals(1, new Rent(dvdR, 5).getProgramPoints());
		assertEquals(1, new Rent(dvdR, 10).getProgramPoints());
		assertEquals(1, new Rent(dvdR, 100).getProgramPoints());
	}
	
	public void testGetProgramPoints3() throws RentalException {
		assertEquals(1, new Rent(dvdN, 1).getProgramPoints());
		assertEquals(2, new Rent(dvdN, 2).getProgramPoints());
		assertEquals(2, new Rent(dvdN, 5).getProgramPoints());
		assertEquals(2, new Rent(dvdN, 10).getProgramPoints());
		assertEquals(2, new Rent(dvdN, 100).getProgramPoints());
	}

}
